package com.bjsxt.rocket;

import com.bjsxt.disruptor.DisruptorTemplate;
import com.bjsxt.disruptor.Order;
import com.bjsxt.domain.EntrustOrder;
import com.bjsxt.util.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Service;

/**
 * @Description:
 * @ClassName: MessageConsumerListener
 * @Author: chenyu
 * @Date: 2025/3/20 11:25
 */
@Service
@Slf4j
public class MessageConsumerListener {

    @Autowired
    private DisruptorTemplate disruptorTemplate ;

    @StreamListener("order_in")  //监听队列order_in
    public  void handleMessage(EntrustOrder entrustOrder){
        Order order = BeanUtil.entrustOrder2Order(entrustOrder);
        log.info("接收到了委托单:{}",order);
        disruptorTemplate.onData(order);
    }
}
